package com.exam.controller;

import com.exam.pojo.Replay;
import com.exam.service.ReplayService;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
public class ReplayController {
    @Resource
    private ReplayService replayService;

    @PostMapping("/replay/add")
    public int add(@RequestBody Replay replay){
        return replayService.add(replay);
    }

    @GetMapping("/replays/{pageNum}/{pageSize}/{name}")
    public PageInfo<Replay> findByNamePage(@PathVariable("pageNum") Integer pageNum,
                                           @PathVariable("pageSize") Integer pageSize,
                                           @PathVariable("name") String replayName){
        return replayService.queryByNamePage(pageNum,pageSize,replayName);
    }
    @PutMapping("/replay/update")
    public int updateById(@RequestBody Replay replay){
        return replayService.updateById(replay);
    }

    @DeleteMapping("/replay/detele/{id}")
    public int deleteById(@PathVariable("id") Integer id){
        return replayService.deleteById(id);
    }
}
